//
//  BLWeatherDetailsForScrollViewButton.m
//  weather
//
//  Created by 大L君的无敌战舰 on 16/4/11.
//  Copyright © 2016年 bigL.com. All rights reserved.
//

#import "BLButtonForWeatherSecondScrollView.h"

@interface BLButtonForWeatherSecondScrollView ()
/* 日期描述 :周末 04/10*/
@property (strong, nonatomic) UILabel * date;
/* 天气描述 */
@property (strong, nonatomic) UILabel * describe;
/* 天气图标 */
@property (strong, nonatomic) UIImageView *weatherImageView;
/* 气温描述 */
@property (strong, nonatomic) UILabel * wind;
/* 预报图标 */
@property (strong, nonatomic) UIImageView *weatherLaterImageView;
@end


@implementation BLButtonForWeatherSecondScrollView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = BLRandomColor(2);
        //加载子控件
        [self setChildView];
        //加载数据
        [self loadData];
    }
    return self;
}



//加载子控件
-(void)setChildView
{
    
    /* 日期描述 :周末 04/10*/
    UILabel * date = [[UILabel alloc]init];
    date.adjustsFontSizeToFitWidth = YES;
    date.font = TextSmallSize;
    date.textAlignment = NSTextAlignmentCenter;
    self.date = date;
    [self addSubview:date];
    //约束
    [date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).with.offset(0);
        make.top.equalTo(self).with.offset(5);
    }];
    
    
    
    /* 天气描述 */
    UILabel * describe = [[UILabel alloc]init];
    describe.font = TextSmallSize;
    self.describe = describe;
    [self addSubview:describe];
    //约束
    [describe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).with.offset(0);
        make.top.equalTo(self.date.mas_bottom).with.offset(5);
    }];
    
    /* 天气图标 */
    UIImageView * weatherImageView = [[UIImageView alloc]init];
    self.weatherImageView = weatherImageView;
    [self addSubview:weatherImageView];
    //约束
    [weatherImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.describe.mas_bottom).with.offset(5);
        make.centerX.equalTo(self.mas_centerX).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(1);
        make.height.equalTo(self.mas_height).multipliedBy(0.1);
    }];
    
    /* 气温描述 */
    UILabel * wind = [[UILabel alloc]init];
    wind.font = TextSmallSize;
    date.adjustsFontSizeToFitWidth = YES;
    self.wind = wind;
    [self addSubview:wind];
    //约束
    [wind mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).with.offset(0);
        make.bottom.equalTo(self).with.offset(-5);
    }];
    
    /* 晚上天气图标 */
    UIImageView * weatherLaterImageView = [[UIImageView alloc]init];
    self.weatherLaterImageView = weatherLaterImageView;
    [self addSubview:weatherLaterImageView];
    //约束
    [weatherLaterImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.wind.mas_top).with.offset(-30);
        make.centerX.equalTo(self.mas_centerX).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(1);
        make.height.equalTo(self.mas_height).multipliedBy(0.1);
        
    }];
}


//加载数据
- (void)loadData
{
    self.describe.text    = @"中雨";
    self.date.text        = @"周末 04/10";
    self.wind.text = @"最低21°C";
    
    self.describe.textColor    = [UIColor whiteColor];
    self.date.textColor        = [UIColor whiteColor];
    self.wind.textColor =   [UIColor whiteColor];
    
    
    
    //    self.describe.backgroundColor = BLRandomColor(1);
    //    self.date.backgroundColor     = BLRandomColor(1);
    //    self.temperature.backgroundColor = BLRandomColor(1);
    
    
    self.weatherImageView.backgroundColor = BLRandomColor(2);
    self.weatherLaterImageView.backgroundColor = BLRandomColor(2);
    
    
}


@end
